package com.tdy.nht.doc.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.tdy.nht.doc.dao.${modelName}Dao;
import com.tdy.nht.doc.domain.${modelName}DO;
import com.tdy.nht.doc.domain.${modelName}Query;
import com.tdy.nht.doc.service.${modelName}Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @Description: $!{annotation}Service组件
* @author: $!{author}
* @date: ${createTime}
*/
@Service
public class ${modelName}ServiceImpl implements ${modelName}Service {


            @Autowired
            private ${modelName}Dao ${lowerModelName}Dao;

#if($!saveMethod == '1')

            @Override
            public int updateSelectiveByPrimary(${modelName}DO ${lowerModelName}DO) {
                return ${lowerModelName}Dao.updateByPrimaryKey(${lowerModelName}DO);
            }
#end

            @Override
            public PageInfo<${modelName}DO> listByPage(${modelName}Query query) {
                PageHelper.offsetPage(query.getOffset(), query.getPageSize());
                List<${modelName}DO> list = ${lowerModelName}Dao.listByPage(query);
                    PageInfo<${modelName}DO> pageInfo = new PageInfo<>(list);
                        return pageInfo;
             }

            @Override
            public int save${modelName}(${modelName}DO ${lowerModelName}DO) {
               return ${lowerModelName}Dao.insert(${lowerModelName}DO);
            }

            @Override
            public ${modelName}DO getDetail(Long id) {
            return ${lowerModelName}Dao.selectByPrimaryKey(id);
            }

            @Override
            public int deleteBatch${modelName}(List<Long> ids) {
                return ${lowerModelName}Dao.deleteBatchByIds(ids);
        }
}
